
library(ggplot2)
library(cluster)
library(factoextra)
library(pheatmap)
library(gridExtra)
library(RColorBrewer)
library(readxl)
library(ggsignif)


data=data.frame(read_excel('./data/1-s2.0-S0092867419313856-mmc2.xlsx',2))

data2=data.frame(read_excel('./data/1-s2.0-S0092867419313856-mmc2.xlsx',2,n_max=2,col_names=F))
names(data)=data2[2,]
temp=data2[1,]
names(data)=gsub('_TenPx.*','',temp)
origdata=data[,c(2,5,49:426)]

origdata[,2]=sapply(strsplit(origdata[,2],'_'),head,1)
##get cell map
map1=data.frame(read_excel('./data/list_aml_proteomics CG.xlsx',2))
map1=map1[map1$Tissue.of.Origin %in% 'Haematopoietic and Lymphoid Tissue',]
map1=map1[!is.na(map1$Column1),]
cell_map=map1
t1=cell_map$Cell.Line
t1=gsub('-','',t1)
t1=gsub(' ','',t1)
t1=gsub('[.]','',t1)
rownames(cell_map)=toupper(t1)

cell_map=cell_map[,7,drop=F]
names(cell_map)='type'

genes=data.frame(read_excel('./data/Mitochondrial genes.xlsx',4))

cell_map[!cell_map$type %in% c('AML','CML','B ALL'),1]='other'
ann_colors = list(is_mito=c(mito='black','other'='white'),type=c('AML'='red','CML'='blue','B ALL'='black',
                                                                 'other'='grey'))


cols = colorRampPalette(c("#2544ce", "#5067ce", "#FAFAFA", "#e26161", "#d10202"))(1055)




curgene='MFN2'
  ind1=match(map1$CCLE.Code[map1$Column1 %in% 'AML'],names(origdata))


  curdata=origdata[match(curgene,toupper(origdata[,1])),]
  curdata=t(curdata)
  curdata=curdata[-c(1,2),]
  curdata=data.frame(curdata,stringsAsFactors = F)
  curdata[,1]=as.numeric(curdata[,1])
  curdata$type='Non AML'
  curdata$type[ind1-2]='AML'
  names(curdata)[1]='Expression'

  
  curdata=curdata[rownames(curdata) %in% map1$CCLE.Code,]


  
  
  
  p1=ggplot(curdata, aes(x=type, y=Expression)) + 
    geom_boxplot()+
    geom_dotplot(binaxis='y', stackdir='center', dotsize=.06)+
    geom_jitter(shape=16, position=position_jitter(0.2))+
    ylab('Normalized Spectral Counts')+
    geom_signif(comparisons = list(c("AML", "Non AML")), 
                map_signif_level=TRUE)+ggtitle(curgene)
 
ggsave('./figures/sFigure_2C.pdf',p1,width=5,height=8,units='in')
